﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HROReporting.Infrastructure.Logging;
using HROReporting.Infrastructure.UnitOfWork;
using HROReporting.Infrastructure.Configuration;
using HROReporting.Infrastructure.Email;
using StructureMap;
using StructureMap.Configuration.DSL;
using HROReporting.Repository.NHibernate;
using HROReporting.Model.Studenten;
using HROReporting.Repository.NHibernate.Repositories;
using HROReporting.Services.Interfaces;
using HROReporting.Services.Implementations;
using HROReporting.Infrastructure.Authentication;
using HROReporting.Controllers.ActionArguments;
using HROReporting.Infrastructure.CookieStorage;
using HROReporting.Model.SchoolLocaties;
using HROReporting.Model.Docenten;
using HROReporting.Model.DocentIncheckingen;
using HROReporting.Model.Lesuren;
using HROReporting.Model.NFCDevices;
using HROReporting.Model.SchoolKantoren;
using HROReporting.Model.PresentieIncheckingen;

namespace HROReporting.UI.Web.MVC
{
    public class BootStrapper
    {
        public static void ConfigureDependencies()
        {
            ObjectFactory.Initialize(x =>
            {
                x.AddRegistry<ControllerRegistry>();

            });
        }

        public class ControllerRegistry : Registry
        {
            public ControllerRegistry()
            {
                // Repositories
                For<IUnitOfWork>().Use<NHUnitOfWork>();
                For<IStudentRepository>().Use<StudentRepository>();
                For<ISchoolLocatieRepository>().Use<SchoolLocatieRepository>();
                For<IDocentRepository>().Use<DocentRepository>();
                For<IDocentIncheckingRepository>().Use<DocentIncheckingRepository>();
                For<ILesuurRepository>().Use<LesuurRepository>();
                For<INFCDeviceRepository>().Use<NFCDeviceRepository>();
                For<ISchoolKantoorRepository>().Use<SchoolKantoorRepository>();
                For<IPresentieIncheckingRepository>().Use<PresentieIncheckingRepository>();

                // Services
                For<IStudentService>().Use<StudentService>();
                For<ISchoolLocatieService>().Use<SchoolLocatieService>();
                For<IDocentService>().Use<DocentService>();
                For<IDocentIncheckingService>().Use<DocentIncheckingService>();
                For<ILesuurService>().Use<LesuurService>();
                For<INFCDeviceService>().Use<NFCDeviceService>();
                For<ISchoolKantoorService>().Use<SchoolKantoorService>();
                For<IPresentieIncheckingService>().Use<PresentieIncheckingService>();

                // Authentication
                For<IFormsAuthentication>().Use<AspFormsAuthentication>();
                For<ILocalAuthenticationService>().Use<AspMembershipAuthentication>();

                // Controller Helpers
                For<IActionArguments>().Use<HttpRequestActionArguments>();

                // Logger
                For<ILogger>().Use<Log4NetAdapter>();

                // Email service
                For<IEmailService>().Use<TextLoggingEmailService>();

                // Application settings
                For<IApplicationSettings>().Use<WebConfigApplicationSettings>();

                For<ICookieStorageService>().Use<CookieStorageService>();
            }
        }
    }
}